/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("tb_project_expensebaseinfo",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using MYData.Entity.DomainModels;
using MYData.System.IServices;
using MYData.Core.Utilities;
using MYData.Entity.DTO.ApiEntity.Input;
using Autofac.Core;
using Microsoft.AspNetCore.Authorization;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Internal;
using System.Net;

namespace MYData.System.Controllers
{
    public partial class tb_project_expensebaseinfoController
    {
        private readonly Itb_project_expensebaseinfoService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public tb_project_expensebaseinfoController(
            Itb_project_expensebaseinfoService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        /// 添加项目报销信息
        /// </summary>
        /// <param name="inputDto"></param>
        /// <returns></returns>
        [HttpPost, Route("InsertBudgetInfo"),AllowAnonymous]
        public IActionResult InsertBudgetInfo([FromBody]BudgetBaseInfoInput_Dto inputDto)
        {
            return Json(_service.InsertBudgetInfo(inputDto));
        }

        /// <summary>
        /// 删除项目经费报销信息(逻辑删除)
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet, Route("SoftDeleteExpenseInfoAsync")]
        public async Task<IActionResult> SoftDeleteExpenseInfoAsync(string ExpenseId)
        {
            return Json(await _service.SoftDeleteExpenseInfoAsync(ExpenseId));
        }

        /// <summary>
        /// 删除项目经费报销信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet, Route("DeleteExpenseInfoAsync")]
        public async Task<IActionResult> DeleteExpenseInfoAsync(string Id)
        {
            return Json(await _service.SoftDeleteExpenseInfoAsync(Id));
        }

        /// <summary>
        /// 修改项目经费报销
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        [HttpPost, Route("UpdateeExpenseInfoAsync")]
        public async Task<IActionResult> UpdateeExpenseInfoAsync([FromBody]UpdateExpenseInfoDto inputDto)
        {
            return Json(await _service.UpdateeExpenseInfoAsync(inputDto));
        }
        /// <summary>
        /// 经费报销显示+查询
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        [HttpPost("GetExpensesReimbursement")]
        public Task<WebResponseContent> GetExpensesReimbursement([FromBody]BillingAllocationSearch_Dto Search)
        {
            return _service.GetExpensesReimbursement(Search);
        }
        /// <summary>
        /// 科目报销显示
        /// </summary>
        /// <param name="ProjectId"></param>
        /// <returns></returns>
        [HttpPost("GetAccountReimbursement")]
        public Task<WebResponseContent> GetAccountReimbursement(string ProjectId)
        {
            return _service.GetAccountReimbursement(ProjectId);
        }

        /// <summary>
        /// 经费报销审批列表
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("expensebaseinfoList")]
        [AllowAnonymous]
        public IActionResult expensebaseinfoList()
        {
            return Json(_service.expensebaseinfoList());
        }

        [HttpGet, Route("getEntity")]
        [AllowAnonymous]
        public IActionResult getEntity()
        {
            Type t = typeof(tb_project_expensebaseinfo);
            MethodInfo[] mi = t.GetMethods();
            var shuchu = "";
            foreach (MethodInfo mi2 in mi)
            {
                //shuchu= shuchu + mi2.Name;
                shuchu = shuchu + mi2.DisplayName;
            }

            return Ok(shuchu);
        }

        [HttpGet, Route("Show")]
        [AllowAnonymous]
        public string Show()
        {
            return "api收到了信息";
        }

        /// <summary>
        /// 根据报销Id获取报销详细信息
        /// </summary>
        /// <param name="applyId"></param>
        /// <returns></returns>
        [HttpGet, Route("GetApplyList"),AllowAnonymous]
        public async Task<IActionResult> GetApplyList(string applyId)
        {
            return Json(await _service.GetApplyList(applyId));
        }

    }
}
